package com.whiteblue.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
/**
 * Created with IntelliJ IDEA.
 * Author: StevenChow
 * Date: 13-5-8
 */
public class LoginValidator extends Validator{
    @Override
    protected void validate(Controller c) {
        validateRegex("id", "\\S{1,5}", "msg", "此id不正确(介于1到5位之间的字符)");
        validateRequired("password", "msg", "密码不能为空");
    }

    @Override
    protected void handleError(Controller c) {
        c.keepPara("id");
        c.render("/user/login.html");
    }
}
